﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace DELVE_GAME.ViewStructure
{
    class MenuChoice2 : MenuComponent
    {
        GameAction enterAction;
        public String menuName;
        SpriteFont menuFont;
        Vector2 position;
        private bool isSelected;
        private bool isVisible;
       
        public MenuChoice2(SpriteBatch spriteBatch, int x, int y, String name, SpriteFont font, bool visible)
        {
            position = new Vector2(x, y);
            menuName = name;
            menuFont = font;
            isSelected = false;
            isVisible = visible;
            
        }

        public void setPosition(int x, int y)
        {
            position.X = x;
            position.Y = y;
        }

        public Vector2 getPosition()
        {
            return position;
        }


        public void setVisibility(bool toggle)
        {
            isVisible = toggle;
        }

        public bool getVisibility()
        {
            return isVisible;
        }
        public override void update()
        {
            base.update();
        }


        public void setEnterAction(GameAction action)
        {
            enterAction = action;
        }

        public void doEnterAction()
        {
            if (enterAction != null)
            {
                enterAction.doAction();
            }
        }

        public void setSelection(bool selection)
        {
            this.isSelected = selection;
        }

        public override void draw(SpriteBatch sb)
        {
            //highlight current selection
            sb.Begin();
            if (isVisible)
            {
                if (this.isSelected)
                    sb.DrawString(menuFont, this.menuName, new Vector2(position.X - menuFont.MeasureString(this.menuName).X / 2, position.Y), Color.Cyan);
                else
                    sb.DrawString(menuFont, this.menuName, new Vector2(position.X - menuFont.MeasureString(this.menuName).X / 2, position.Y), Color.White);
            } 
            sb.End();
        }
    
    }
}
